<template>
  <div class="w">
    <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
      <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
        <div v-for="(item,index) in list_box" :key="index" class="item_box">
          <p>收藏时间:{{item.create_time}}</p>
          <van-card  :price="item.goods_price" desc="描述信息" :title="item.goods_name" :thumb="item.goods_icon" />
        </div>
        </van-list>
    </van-pull-refresh>
  </div>
</template>
<style lang="" scoped>
  .w{
    padding-top: 1rem;
  }
  .item_box{
    margin-bottom: 0.5rem;
  }
  .item_box p{
    color: #999999;
    margin-bottom: 0.1rem;
    font-size: 0.24rem;
  }

</style>
<script>
  import getData from '@/assets/js/axios.js'
  export default {
    data() {
      return {
        loading: false,
        finished: false,
        refreshing: false,
        alllist: '',
        page: 1,
        //列表展示
        list_box: [],
      }
    },
    mounted() {
      // getData.goodColhist().then(res=>{
      //   console.log(res,'收藏列表信息')

      // }).catch(err=>{

      // })


    },
    methods: {
      onLoad() {
        if (this.refreshing) {
          this.list_box = [];
          this.refreshing = false;
        }
        var para = {
          "page": this.page,
          // "goods_category": idnumber
        };
        //console.log(this.page,"页数")   
        getData.goodColhist(para).then(res => {

          console.log(res.data.data.list.data, "总量")
          this.list_box.push(...res.data.data.list.data);
          //console.log(this.list_box,3636);
          this.page++;
          this.loading = false;
          console.log(res, this.page, "下拉刷新的")
          //console.log(this.list_box,3636);
          if (this.list_box.length >= res.data.data.list.total) {
            this.finished = true
          }
        }).catch(err => {

        })




      },

      // 加载失败调用方法
      onRefresh() {
        console.log("失败了")
        this.finished = false; 		// 清空列表数据
        this.loading = true; 			// 将 loading 设置为 true，表示处于加载状态
        this.page = 1;				// 分页数赋值为1
        this.list_box = [];				// 清空数组
        this.onLoad(); 				// 重新加载数据
      },



    }


  }
</script>